import Vue from 'vue'
import element from 'element-ui'
import moment from 'moment'
import compositionApi from '@vue/composition-api'
import _variable from 'styles/export-js.styl'
import store from './store'
import App from './App'

// import 'normalize.css'
import 'styles/index.styl'

// 不能使用es6 import('xxx') 因为它是异步 载入 mock 必须同步
if (process.env.NODE_ENV == 'development') {
  require('./mock')
}

moment.locale('zh-cn')

Vue.use(compositionApi)
Vue.use(element)

Vue.prototype.moment = moment
Vue.prototype._variable = _variable
Vue.config.productionTip = false
Vue.config.devtools = process.env.NODE_ENV == 'development'

/**
 * 初始化 vue 实例
 *
 * @param {import('vue').Component} Component
 * @param {string | HTMLElement} [el='#app']
 * @param {Omit<import('vue').ComponentOptions, 'render' | 'store'>} [options={}]
 */
export function createApp(Component, el = '#app', options = {}) {
  new Vue({
    render: h => h(App, [h(Component)]),
    store,
    ...options
  }).$mount(el)
}
